<?php

namespace App\Common\Http\Request;

use Hyperf\Validation\Request\FormRequest;

class UserSaveRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return true;
    }


    /**
     * Get the validation rules that apply to the request.
     */
    public function rules(): array
    {
        return [
            'nickname' => 'required',
            'headerImage' => 'url',
            'gender' => 'in:0,1,2',
            'profession' => 'in:0,1,2',
            'email' => 'email|unique:user',
            'phone' => ["regex:/^0{0,1}(13[0-9]|15[7-9]|153|156|18[7-9])[0-9]{8}$/"],
        ];
    }

    public function messages(): array
    {
        return [
            'nickname.required' => '昵称必填',
            'gender.in' => '请正确选择性别',
            'profession.in' => '请正确选择职业',
            'email.email' => '邮箱格式错误',
            'email.unique' => '邮箱已被占用',
            'phone.regex' => '手机号格式不正确',
            'headerImage.url' => '头像地址无法访问'
        ];
    }
}